#include "AutoFreeAlloc.h"

// -------------------------------------------------------------------------
// class TestAutoFreeAlloc

class TestAutoFreeAlloc
{
public:
	class Obj
	{
	private:
		int m_val;
	public:
		Obj(int arg = 0) {
			m_val = arg;
			printf("construct Obj: %d\n", m_val);
		}
		~Obj() {
			printf("destruct Obj: %d\n", m_val);
		}
	};

	static void doTest()
	{
		std::AutoFreeAlloc alloc;
		
		Obj* o1 = NEW(alloc, Obj)(1);
		Obj* o2 = NEW_ARRAY(alloc, Obj, 8);
		Obj* o3 = ALLOC_ARRAY(alloc, Obj, 10); // NOTE
		
		char* s1 = ALLOC(alloc, char);
		char* s2 = ALLOC_ARRAY(alloc, char, 100);
		memcpy(s2, "hello\n", 7);
		printf(s2);

		int* i1 = NEW(alloc, int)(3);
		int* i2 = NEW_ARRAY(alloc, int, 80);
	}
};

int
main() {
	TestAutoFreeAlloc::doTest() ;
}
